# Maintainer (MSYS2): Michael Hansen <zrax0111@gmail@com>

_realname=editorconfig-core-c
pkgbase=mingw-w64-${_realname}
pkgname=("${MINGW_PACKAGE_PREFIX}-${_realname}")
pkgver=0.12.3
pkgrel=2
pkgdesc='EditorConfig core code written in C (mingw-w64)'
url='https://github.com/editorconfig/editorconfig-core-c'
arch=('any')
license=('BSD')
depends=("${MINGW_PACKAGE_PREFIX}-pcre2")
makedepends=("${MINGW_PACKAGE_PREFIX}-cmake"
             "${MINGW_PACKAGE_PREFIX}-doxygen")
source=("${_realname}-${pkgver}.tar.gz::https://github.com/editorconfig/${_realname}/archive/v${pkgver}.tar.gz")
sha256sums=('64edf79500e104e47035cace903f5c299edba778dcff71b814b7095a9f14cbc1')

prepare() {
  mkdir -p build-${MINGW_CHOST}
}

build() {
  cd build-${MINGW_CHOST}

  MSYS2_ARG_CONV_EXCL="-DCMAKE_INSTALL_PREFIX=" \
  ${MINGW_PREFIX}/bin/cmake \
    -G"MSYS Makefiles" \
    -DCMAKE_INSTALL_PREFIX="${MINGW_PREFIX}" \
    -DCMAKE_BUILD_TYPE=Release \
    ../${_realname}-${pkgver}

  make
}

package() {
  cd build-${MINGW_CHOST}

  make DESTDIR="${pkgdir}" install
  install -Dm644 "${srcdir}/${_realname}-${pkgver}/LICENSE" "${pkgdir}/${MINGW_PREFIX}/share/licenses/${_realname}/LICENSE"
}
